
from PIL import Image,ImageEnhance,ImageFilter
import uuid

im = Image.open("d:/box/captcha/src/e4258924-871d-11e7-b739-00090ffe0001.png")

#im.show()

enhancer = ImageEnhance.Contrast(im)
#去除干扰
im = enhancer.enhance(5)
# 去背景色
imgry = im.convert('1')
data = imgry.getdata()
w,h = imgry.size


# 切割图片
imgCrop1 = imgry.crop((5,0,18,20))
imgCrop1.save("d:/box/captcha/category/unknown/%s.png"%uuid.uuid4())
imgCrop2 = imgry.crop((19,0,30,20))
imgCrop2.save("d:/box/captcha/category/unknown/%s.png"%uuid.uuid4())
imgCrop3 = imgry.crop((31,0,44,20))
imgCrop3.save("d:/box/captcha/category/unknown/%s.png"%uuid.uuid4())
imgCrop4 = imgry.crop((45,0,56,20))
imgCrop4.save("d:/box/captcha/category/unknown/%s.png"%uuid.uuid4())
#imgry.show()